import VueRouter from "vue-router";
import review from "../views/video-management/review";
import category from "../views/video-management/category";
import upload from "../views/video-management/upload";
import edit from "../views/video-management/edit";
import hot from "../views/video-management/hot";
// import Vue from "vue";
import login from "../views/login.vue";
import home from "../views/home.vue";
// import { Message } from "element-ui";
const RouterPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(to) {
  return RouterPush.call(this, to).catch((err) => err);
};
const RouterReplace = VueRouter.prototype.replace;
VueRouter.prototype.replace = function replace(to) {
  return RouterReplace.call(this, to).catch((err) => err);
};
const router = new VueRouter({
  mode: "history",
  base: process.env.BASE_URL,
  routes: [
    {
      path: "/login",
      component: login,
    },
    {
      path: "/home",
      component: home,
      children: [
        {
          path: "video-management/review",
          component: review,
        },
        {
          path: "video-management/hot",
          component: hot,
        },
        {
          path: "video-management/category",
          component: category,
        },
        {
          path: "video-management/upload",
          component: upload,
        },
        {
          path: "video-management/edit",
          component: edit,
        },
      ],
    },
    {
      path: "/",
      redirect: "/home",
    },
  ],
});
// router.beforeEach((to, from, next) => {
//   const user = Vue.$cookies.get("cookie");
//   if ((to.path.includes("/user") || to.path === "/home/interests") && !user) {
//     Message({ message: "你还没有登录噢~快去登录一下吧！", type: "warning" });
//     next("/login");
//   } else {
//     next();
//   }

//   if (to.path == "/setting/basic" && !$cookies.get("cookie")) {
//     next("/setting/play");
//   }
// });
export default router;
